import express from "express";
import multer from "multer";
import { ImportService } from "../../services/province/importService.mjs";

const router = express.Router();
const upload = multer({ dest: "uploads/" });

/**
 * @swagger
 * /api/province/import:
 *   post:
 *     summary: 导入省份数据
 *     description: 导入省份数据
 *     responses:
 *       200:
 *         description: 数据导入成功
 */
router.post("/", upload.single("provinceData"), async (req, res) => {
  try {
    const result = await ImportService.importProvinceData(req.file);
    res.json(result);
  } catch (error) {
    console.error("导入错误:", error);
    res.status(500).json({ message: error.message });
  }
});

export default router;
